package com.yhy.wxzn.wcs.device.netty.bean;

import com.yhy.wxzn.wcs.device.netty.enumerate.SiemensPLCS;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class HeadData {
    private byte[] plcHead1 = new byte[]{3, 0, 0, 22, 17, -32, 0, 0, 0, 1, 0, -64, 1, 10, -63, 2, 1, 2, -62, 2, 1, 0};
    private byte[] plcHead2 = new byte[]{3, 0, 0, 25, 2, -16, -128, 50, 1, 0, 0, 4, 0, 0, 8, 0, 0, -16, 0, 0, 1, 0, 1, 1, -32};
    private byte[] plcHead1_200 = new byte[]{3, 0, 0, 22, 17, -32, 0, 0, 0, 1, 0, -63, 2, 77, 87, -62, 2, 77, 87, -64, 1, 9};
    private byte[] plcHead2_200 = new byte[]{3, 0, 0, 25, 2, -16, -128, 50, 1, 0, 0, 0, 0, 0, 8, 0, 0, -16, 0, 0, 1, 0, 1, 3, -64};
    private byte[] plcHead1_200smart = new byte[]{3, 0, 0, 22, 17, -32, 0, 0, 0, 1, 0, -63, 2, 16, 0, -62, 2, 3, 0, -64, 1, 10};
    private byte[] plcHead2_200smart = new byte[]{3, 0, 0, 25, 2, -16, -128, 50, 1, 0, 0, -52, -63, 0, 8, 0, 0, -16, 0, 0, 1, 0, 1, 3, -64};

    public HeadData() {
    }

    public void setPlcType(SiemensPLCS siemens) {
        switch(siemens) {
            case S200:
                this.plcHead1 = this.plcHead1_200;
                this.plcHead2 = this.plcHead2_200;
                break;
            case S300:
                this.plcHead1[21] = 2;
                break;
            case S400:
                this.plcHead1[17] = 0;
                this.plcHead1[21] = 3;
                break;
            case S200Smart:
                this.plcHead1 = this.plcHead1_200smart;
                this.plcHead2 = this.plcHead2_200smart;
                break;
            case S1200:
            case S1500:
                this.plcHead1[21] = 0;
        }

    }

    public ByteBuf getPlcHead1() {
        return Unpooled.wrappedBuffer(this.plcHead1);
    }

    public ByteBuf getPlcHead2() {
        return Unpooled.wrappedBuffer(this.plcHead2);
    }
}
